﻿using UnityEngine;
using System.Collections;
using System.Threading;

public class AniEffectAni : AniEffectC {

	public float delaySecond;

	public AniBase aniBase;
	
	public override void play (OReportDetail detail, CallBack finished) {
		if(finished != null && delaySecond > 0) {
			StartCoroutine(GameMonoUtils.getDelayCallBack(delaySecond * AniBase.Speed, finished));
			finished = null;
		}

//		if(finished == null) {
//			finished = ()=>{Destroy(gameObject);};
//
//		} else {
//			finished = ()=>{Destroy(gameObject);finished();};
//		}

		if(aniBase == null) {
			finished();

		} else {
			aniBase.gameObject.SetActive(true);
			playAniBase(aniBase, detail, finished);
		}
	}

	protected virtual void playAniBase(AniBase aniBase, OReportDetail detail, CallBack finished) {
		aniBase.playCallBack(finished);
	}
}
